You'll need to create or get handles to Reflection terminal controls and views for most of your applications:
Refer to the following tables for ways to get and create terminal (control) and view objects.
The following methods can be used to get a handle to an existing control or to create a new control.
Use this API call |
To get |
GetControlsByFilePath() |
A collection of open terminal emulation sessions. This method requires the path to a saved session document and returns a collection of all open emulation sessions that were created from that file. |
GetControlByInstanceId() |
An open terminal emulation session. This method requires the session's instance ID. A unique instance ID is created for a session each time you open the session document. |
CreateControl(filePath) |
A new terminal emulation session by specifying the file path for an existing session document. |
CreateControl(Guid controlType)
|
A new terminal emulation session. Each session type requires a different GUID controlType. 3270 (IBM): Guid("{09E5A1B4-0BA6-4546-A27D-FE4762B7ACE1}") 5250 (IBM): Guid("{AF03A446-F278-4624-B9EF-C896DF2CA1CA}") UNIX and OpenVMS (OpenSystems): Guid("{BE835A80-CAB2-40d2-AFC0-6848E486BF58}") ReGIS Graphics (OpenSystems): Guid("{C62BA7E4-5A20-4681-931B-07BF7C971D13}") |
|
|
|
|
|
|
|
Each of the following methods gets the View object associated with a control.
When using this method |
Provide this parameter |
GetViewByTitleText() |
The Name property from the Tab Properties dialog box of the session document view. For example, GetViewByTitleText(MySession.rd3x). Note: To open the Tab Properties dialog box, right-click the session tab in the Reflection Workspace and choose Properties. |
GetViewByInstanceID() |
The API tab identifier number in the Tab Properties dialog box of the open session document. Each time you create a session document view, a new number is generated. (The API tab identifier of a View is different from that of the embedded control.) |
GetViewsByFilePath() |
The path to which the session or Web page document has been saved. |
Note: To re-create a View object after closing it, you must first re-create the control that will be associated with the View.
This sample gets the host session document that has focus in the Reflection workspace by getting the view object for that session.
Note: This program works only with host session documents; not Web page documents.
Get the selected view |
Copy Code
|
---|---|
//This sample gets the selected view in a running Reflection workspace that has two running sessions. //If more than one instance of Reflection is running, the sessions must be running in the first instance that was started. using System; using System.Collections.Generic; using System.Text; using Attachmate.Reflection.Framework; using Attachmate.Reflection.Emulation.IbmHosts; using Attachmate.Reflection.Emulation.OpenSystems; using Attachmate.Reflection.UserInterface; namespace GetViewsByTitleText { class Program { static void Main(string[] args) { //Get a handle to an application that represents the first instance of Reflection started manually. //For production code, use a try catch block here to handle a System Application Exception thrown //if the app isn't running. Application app = MyReflection.CreateApplication(); //Get the frame and the selected view IFrame frame = (IFrame)app.GetObject("Frame"); IView view = frame.SelectedView; //If the IBM view is selected, get some text from its screen if (view.TitleText == "mySession.rd3x") { IIbmTerminal terminalIBM = (IIbmTerminal)view.Control; IIbmScreen screenIBM = terminalIBM.Screen; Console.WriteLine(screenIBM.GetTextEx(1, 1, screenIBM.Rows, screenIBM.Columns, GetTextArea.Block, GetTextWrap.Off, GetTextAttr.Any, GetTextFlags.None)); } //If the Open Systems view is selected, get some text from its screen if (view.TitleText == "mySession.rdox") { ITerminal terminalOS = (ITerminal)view.Control; IScreen screenOS = terminalOS.Screen; Console.WriteLine(screenOS.GetText(1, 1, screenOS.DisplayRows, screenOS.DisplayColumns)); } } } } |
This sample gets both the Views and Controls for two sessions by referencing the title text of the Views.
Get views by title text |
Copy Code
|
---|---|
//This sample gets the views of two sessions running in a workspace. //If more than one instance of is running, the sessions must be running in the first instance that was started. using System; using System.Collections.Generic; using System.Text; using Attachmate.Reflection.Framework; using Attachmate.Reflection.Emulation.IbmHosts; using Attachmate.Reflection.Emulation.OpenSystems; using Attachmate.Reflection.UserInterface; namespace GetViewsByTitleText { class Program { static void Main(string[] args) { //Get a handle to an application that represents the first instance of started manually. //For production code, use a try catch block here to handle a System Application Exception thrown //if the app isn't running. Application app = MyReflection.CreateApplication(); IFrame frame = (IFrame)app.GetObject("Frame"); //Get the IBM view and then get some text from its screen IView viewIBM = frame.GetViewByTitleText("mySession.rd3x"); if (viewIBM != null) { IIbmTerminal terminalIBM = (IIbmTerminal)viewIBM.Control; IIbmScreen screenIBM = terminalIBM.Screen; Console.WriteLine(screenIBM.GetTextEx(1, 1, screenIBM.Rows, screenIBM.Columns, GetTextArea.Block, GetTextWrap.Off, GetTextAttr.Any, GetTextFlags.None)); } //Get the Open Systems view and then get some text from its screen IView viewOS = frame.GetViewByTitleText("mySession.rdox"); if (viewOS != null) { ITerminal terminalOS = (ITerminal)viewOS.Control; IScreen screenOS = terminalOS.Screen; Console.WriteLine(screenOS.GetText(1, 1, screenOS.DisplayRows, screenOS.DisplayColumns)); } } } } |